using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication11.Models.Mapping
{
    public class alert_targetMap : EntityTypeConfiguration<alert_target>
    {
        public alert_targetMap()
        {
            // Primary Key
            this.HasKey(t => t.alert_target_id);

            // Properties
            this.Property(t => t.target_id)
                .HasMaxLength(50);

            this.Property(t => t.taget_name)
                .HasMaxLength(50);

            this.Property(t => t.mobile_no)
                .HasMaxLength(50);

            this.Property(t => t.Email_addr)
                .HasMaxLength(50);

            this.Property(t => t.Mail_addr)
                .HasMaxLength(200);

            this.Property(t => t.post_code)
                .IsFixedLength()
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("alert_target");
            this.Property(t => t.alert_target_id).HasColumnName("alert_target_id");
            this.Property(t => t.target_id).HasColumnName("target_id");
            this.Property(t => t.role_id).HasColumnName("role_id");
            this.Property(t => t.taget_name).HasColumnName("taget_name");
            this.Property(t => t.mobile_no).HasColumnName("mobile_no");
            this.Property(t => t.Email_addr).HasColumnName("Email_addr");
            this.Property(t => t.Mail_addr).HasColumnName("Mail_addr");
            this.Property(t => t.post_code).HasColumnName("post_code");
            this.Property(t => t.service_seq).HasColumnName("service_seq");

            // Relationships
            this.HasRequired(t => t.alert_target2)
                .WithOptional(t => t.alert_target1);

        }
    }
}
